package com.neusoft.elm.controller;

import com.neusoft.elm.po.Business;
import com.neusoft.elm.service.BusinessService;
import com.neusoft.elm.service.Impl.BusinessServiceImpl;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 商家
 * Controller层
 */
public class BusinessController {

    /**
     * 根据分类编号查询商家信息
     *
     * @param request
     * @return
     * @throws Exception
     */
    public Object listBusinessByOrderTypeId(HttpServletRequest request) throws Exception{
        //从请求参数中获取分类编号
        Integer orderTypeId = Integer.valueOf(request.getParameter("orderTypeId"));
        //进入service层
        BusinessService businessService = new BusinessServiceImpl();
        List<Business> list = businessService.listBusinessByOrderTypeId(orderTypeId);
        //向前端返回数据
        return list;
    }

    /**
     * 根据商家编号查询商家信息
     *
     * @param request
     * @return
     * @throws Exception
     */
    public Object getBusinessById(HttpServletRequest request)throws Exception{
        //从前端获取数据
        Integer businessId = Integer.valueOf(request.getParameter("businessId"));
        //进入service层
        BusinessService service = new BusinessServiceImpl();
        Business business = service.getBusinessById(businessId);
        //向前端返回数据
        return business;
    }
}
